package com.bkgy.controller.tcoilslit.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bkgy.commom.model.QueryDTO;
import com.bkgy.controller.tcoilslit.dto.TCoilSlitDto;
import com.bkgy.controller.tcoilslit.dto.TCoilSlitReportDto;
import com.bkgy.controller.tcoilslit.entity.TCoilSlit;
import com.bkgy.controller.tcoilslit.service.TCoilSlitService;
import com.bkgy.sys.common.entity.ResultData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;


/**
 * 带钢信息
 */
@RestController
@RequestMapping("/tcoil")
public class TCoilSlitController {

    @Autowired
    private TCoilSlitService tCoilSlitService;


    @Operation(summary = "分卷分页查", description = "根据条件分页查询分卷信息")
    @PostMapping("/findTCoilByPage")
    public ResultData<Page<TCoilSlit>> findTCoilByPage(@Parameter(description = "查询条件和分页信息") @RequestBody QueryDTO<TCoilSlitDto> queryDTO) {
        return tCoilSlitService.findTCoilByPage(queryDTO);
    }

    @Operation(summary = "获取分卷报表整体", description = "根据时间查询分卷整体信息")
    @GetMapping("/getAggregatedData")
    public ResultData<TCoilSlitReportDto> getAggregatedData(@RequestParam(required = false, name = "timeType") Object timeType) {
        LocalDate date = LocalDate.now();
        return tCoilSlitService.getAggregatedData(timeType.toString(), date);
    }

}

